package com.leetcode.题库;

/**
 * @author 覃国强
 * @date 2022-03-16 19:55
 */
public class 题库_0027_移除元素 {

  static
  class Solution {
    public int removeElement(int[] nums, int val) {
      if (nums == null || nums.length == 0) {
        return 0;
      }
      int slow = 0;
      for (int fast = 0; fast < nums.length; ++fast) {
        if (nums[fast] != val) {
          nums[slow++] = nums[fast];
        }
      }
      return slow;
    }
  }

}
